-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support for JSON string in defaultImage field for overriding pipeline specific images in the mappings #293
base: main
Are you sure you want to change the base?
Support for JSON string in defaultImage field for overriding pipeline specific images in the mappings #293
Conversation
08e0bf9
to
ddfb96b
Compare
…line specific images in mappings
3e48a78
to
57b5ef7
Compare
This commit expands the test coverage to ensure more robust behavior and refactors the `overridePipelineImages` function to improve error handling and readability.
57b5ef7
to
aca9cc8
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM as it works, but I suggested some code changes. I'll open a separate branch to share with you to facilitate.
worker/docker.go
Outdated
|
||
// Handle JSON format for multiple pipeline images. | ||
var imageMap map[string]string | ||
if err := json.Unmarshal([]byte(imageOverrides), &imageMap); err == nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
WDYT of implementing a simple "json flag" abstrraction like this? There are some advantages:
- Clearer error handling. If the JSON is bad it will fail on startup, not here
- Cleaner logic here, no need to handle parsing
- Minor: A bit more performant since we're not parsing the flag every time
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Edit: Just saw that this inline edits the consts declared in this file. I'd say that's a sub-ideal since we now have consts that are not really the values that might be used in runtime. Some of the advantages I made above don't make sense as I guess this logic is run only once, so nevermind the JSON flag if you stay with this approach.
OTOH I think mutating the static variables can be a little error prone and harder to understand/debug. We now have "consts" in the file that are not really what might be used in runtime. A cleaner logic IMO would be to hold on to the override map in the docker manager instead, and change the getContainerImageName
function to handle the override map instead. I think the logic might be simpler to understand as well. WDYT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point and solution thanks!
worker/docker.go
Outdated
if pipeline == "base" { | ||
defaultBaseImage = image | ||
continue | ||
} | ||
|
||
// Check and update the pipeline images. | ||
if _, exists := pipelineToImage[pipeline]; exists { | ||
pipelineToImage[pipeline] = image | ||
} else if _, exists := livePipelineToImage[pipeline]; exists { | ||
livePipelineToImage[pipeline] = image |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the override JSON format could be improved to avoid multiple conflicts here. We have 3 different identifiers as keys on the same map:
- the special
base
image name which is used as the default here - the batch pipeline image names (which comes from the
pipeline_id
) - the live pipeline image names (which comes from the
model_id
)
All of these values could conflict with each other. I think we could have a layered JSON and avoid this, like:
type ImageOverrides struct {
Default string
Batch map[string]string
Live map[string]string
}
Then we access each of them independently. WDYT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Love it 😍. I did briefly have just this but then removed it again to keep changes minimal.
@rickstaa here's a branch with my suggested changes: aca9cc8...vg/update/ai-runner-image-flag-support Keep in mind I only updated |
Thanks will do! |
This commit ensures the tests are compatible with the new image overrides behavoir.
This commit enhances the worker tests by introducing cases to verify the behavior of image overrides.
…des` This commit introduces deprecation logic for the `aiRunnerImage` flag, replacing it with a new `aiRunnerImageOverrides` flag. The new flag is designed to support enhanced image override functionality as implemented in the worker logic in [ai-worker PR livepeer#293](livepeer/ai-worker#293).
Towards closing 'livepeer/bounties/#69
This PR adds support for processing JSON string in
defaultImage
and specifies pipeline-specific images as key-value pairs with their mappings being updated to overridecontainerImage
.go-livepeer
PR which it supports is #3284cc @rickstaa